home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / PInterfaces / CursorDevices.p < prev    next >
Encoding:
Text File  |  1995-07-06  |  7.2 KB  |  214 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        CursorDevices.p
  3.  
  4.      Contains:    Cursor Devices (mouse/trackball/etc) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT CursorDevices;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __CURSORDEVICES__}
  30. {$SETC __CURSORDEVICES__ := 1}
  31.  
  32. {$I+}
  33. {$SETC CursorDevicesIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __MIXEDMODE__}
  43. {$I MixedMode.p}
  44. {$ENDC}
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49. {
  50.                        * * *  W A R N I N G  * * * 
  51.  
  52.     On currently shipping PowerMacs, the CursorDevices manager is implemented
  53.     in 68K code and emulated.  Unfortunately, the MixedMode glue in InterfaceLib
  54.     is incorrect.  It and the 1.0 version of this file had incorrect parameter
  55.     lists for most functions.
  56.     
  57.     As a first step to avoid runtime errors, the functions in this file were 
  58.     renamed (e.g. from"CrsrDevButtons" to "CursorDeviceButtons").  This will result
  59.     in a link time error if a PowerPC application tries to call the functions.
  60.     When InterfaceLib is fixed, the new names will be exported and PowerPC
  61.     code will then be able to call them.
  62.     
  63. }
  64.     
  65. TYPE
  66.     ButtonOpcode = INTEGER;
  67.  
  68. { ButtonOpcodes }
  69.  
  70. CONST
  71.     kButtonNoOp                    = 0;                            { No action for this button }
  72.     kButtonSingleClick            = 1;                            { Normal mouse button }
  73.     kButtonDoubleClick            = 2;                            { Click-release-click when pressed }
  74.     kButtonClickLock            = 3;                            { Click on press, release on next press }
  75.     kButtonCustom                = 6;                            { Custom behavior, data = CursorDeviceCustomButtonUPP }
  76.  
  77. { Device Classes }
  78.     kDeviceClassAbsolute        = 0;                            { a flat-response device }
  79.     kDeviceClassMouse            = 1;                            { mechanical or optical mouse }
  80.     kDeviceClassTrackball        = 2;                            { trackball }
  81.     kDeviceClass3D                = 6;                            { a 3D pointing device }
  82.  
  83. { Structures used in Cursor Device Manager calls }
  84.  
  85. TYPE
  86.     CursorData = RECORD
  87.         nextCursorData:            ^CursorData;                            { next in global list }
  88.         displayInfo:            Ptr;                                    { unused (reserved for future) }
  89.         whereX:                    Fixed;                                    { horizontal position }
  90.         whereY:                    Fixed;                                    { vertical position }
  91.         where:                    Point;                                    { the pixel position }
  92.         isAbs:                    BOOLEAN;                                { has been stuffed with absolute coords }
  93.         buttonCount:            SInt8; (* UInt8 *)                        { number of buttons currently pressed }
  94.         screenRes:                INTEGER;                                { pixels per inch on the current display }
  95.         privateFields:            ARRAY [0..21] OF INTEGER;                { fields use internally by CDM }
  96.     END;
  97.  
  98.     CursorDataPtr = ^CursorData;
  99.  
  100.     CursorDevice = RECORD
  101.         nextCursorDevice:        ^CursorDevice;                            { pointer to next record in linked list }
  102.         whichCursor:            ^CursorData;                            { pointer to data for target cursor }
  103.         refCon:                    LONGINT;                                { application-defined }
  104.         unused:                    LONGINT;                                { reserved for future }
  105.         devID:                    OSType;                                    { device identifier (from ADB reg 1) }
  106.         resolution:                Fixed;                                    { units/inch (orig. from ADB reg 1) }
  107.         devClass:                SInt8; (* UInt8 *)                        { device class (from ADB reg 1) }
  108.         cntButtons:                SInt8; (* UInt8 *)                        { number of buttons (from ADB reg 1) }
  109.         filler1:                SInt8; (* UInt8 *)                        { reserved for future }
  110.         buttons:                SInt8; (* UInt8 *)                        { state of all buttons }
  111.         buttonOp:                ARRAY [0..7] OF SInt8; (* UInt8 *)        { action performed per button }
  112.         buttonTicks:            ARRAY [0..7] OF LONGINT;                { ticks when button last went up (for debounce) }
  113.         buttonData:                ARRAY [0..7] OF LONGINT;                { data for the button operation }
  114.         doubleClickTime:        LONGINT;                                { device-specific double click speed }
  115.         acceleration:            Fixed;                                    { current acceleration }
  116.         privateFields:            ARRAY [0..14] OF INTEGER;                { fields used internally to CDM }
  117.     END;
  118.  
  119.     CursorDevicePtr = ^CursorDevice;
  120.  
  121. { for use with CursorDeviceButtonOp when opcode = kButtonCustom }
  122.     {
  123.         CursorDeviceCustomButtonProcPtr uses register based parameters on the 68k and cannot
  124.         be written in or called from a high-level language without the help of
  125.         mixed mode or assembly glue.
  126.  
  127.         In:
  128.          => ourDevice       A2.L
  129.          => button          D3.W
  130.     }
  131.     CursorDeviceCustomButtonProcPtr = Register68kProcPtr;  { register PROCEDURE CursorDeviceCustomButton(ourDevice: CursorDevicePtr; button: INTEGER); }
  132.     CursorDeviceCustomButtonUPP = UniversalProcPtr;
  133.  
  134. CONST
  135.     uppCursorDeviceCustomButtonProcInfo = $000ED802; { Register PROCEDURE (4 bytes in A2, 2 bytes in D3); }
  136.  
  137. FUNCTION NewCursorDeviceCustomButtonProc(userRoutine: CursorDeviceCustomButtonProcPtr): CursorDeviceCustomButtonUPP;
  138.     {$IFC NOT GENERATINGCFM }
  139.     INLINE $2E9F;
  140.     {$ENDC}
  141.  
  142. PROCEDURE CallCursorDeviceCustomButtonProc(ourDevice: CursorDevicePtr; button: INTEGER; userRoutine: CursorDeviceCustomButtonUPP);
  143.     {$IFC NOT GENERATINGCFM}
  144.     {To be implemented:  Glue to move parameters into registers.}
  145.     {$ENDC}
  146.  
  147. FUNCTION CursorDeviceMove(ourDevice: CursorDevicePtr; deltaX: LONGINT; deltaY: LONGINT): OSErr;
  148.     {$IFC NOT GENERATINGCFM}
  149.     INLINE $7000, $AADB;
  150.     {$ENDC}
  151. FUNCTION CursorDeviceMoveTo(ourDevice: CursorDevicePtr; absX: LONGINT; absY: LONGINT): OSErr;
  152.     {$IFC NOT GENERATINGCFM}
  153.     INLINE $7001, $AADB;
  154.     {$ENDC}
  155. FUNCTION CursorDeviceFlush(ourDevice: CursorDevicePtr): OSErr;
  156.     {$IFC NOT GENERATINGCFM}
  157.     INLINE $7002, $AADB;
  158.     {$ENDC}
  159. FUNCTION CursorDeviceButtons(ourDevice: CursorDevicePtr; buttons: INTEGER): OSErr;
  160.     {$IFC NOT GENERATINGCFM}
  161.     INLINE $7003, $AADB;
  162.     {$ENDC}
  163. FUNCTION CursorDeviceButtonDown(ourDevice: CursorDevicePtr): OSErr;
  164.     {$IFC NOT GENERATINGCFM}
  165.     INLINE $7004, $AADB;
  166.     {$ENDC}
  167. FUNCTION CursorDeviceButtonUp(ourDevice: CursorDevicePtr): OSErr;
  168.     {$IFC NOT GENERATINGCFM}
  169.     INLINE $7005, $AADB;
  170.     {$ENDC}
  171. FUNCTION CursorDeviceButtonOp(ourDevice: CursorDevicePtr; buttonNumber: INTEGER; opcode: ButtonOpcode; data: LONGINT): OSErr;
  172.     {$IFC NOT GENERATINGCFM}
  173.     INLINE $7006, $AADB;
  174.     {$ENDC}
  175. FUNCTION CursorDeviceSetButtons(ourDevice: CursorDevicePtr; numberOfButtons: INTEGER): OSErr;
  176.     {$IFC NOT GENERATINGCFM}
  177.     INLINE $7007, $AADB;
  178.     {$ENDC}
  179. FUNCTION CursorDeviceSetAcceleration(ourDevice: CursorDevicePtr; acceleration: Fixed): OSErr;
  180.     {$IFC NOT GENERATINGCFM}
  181.     INLINE $7008, $AADB;
  182.     {$ENDC}
  183. FUNCTION CursorDeviceDoubleTime(ourDevice: CursorDevicePtr; durationTicks: LONGINT): OSErr;
  184.     {$IFC NOT GENERATINGCFM}
  185.     INLINE $7009, $AADB;
  186.     {$ENDC}
  187. FUNCTION CursorDeviceUnitsPerInch(ourDevice: CursorDevicePtr; resolution: Fixed): OSErr;
  188.     {$IFC NOT GENERATINGCFM}
  189.     INLINE $700A, $AADB;
  190.     {$ENDC}
  191. FUNCTION CursorDeviceNextDevice(VAR ourDevice: CursorDevicePtr): OSErr;
  192.     {$IFC NOT GENERATINGCFM}
  193.     INLINE $700B, $AADB;
  194.     {$ENDC}
  195. FUNCTION CursorDeviceNewDevice(VAR ourDevice: CursorDevicePtr): OSErr;
  196.     {$IFC NOT GENERATINGCFM}
  197.     INLINE $700C, $AADB;
  198.     {$ENDC}
  199. FUNCTION CursorDeviceDisposeDevice(ourDevice: CursorDevicePtr): OSErr;
  200.     {$IFC NOT GENERATINGCFM}
  201.     INLINE $700D, $AADB;
  202.     {$ENDC}
  203.  
  204. {$ALIGN RESET}
  205. {$POP}
  206.  
  207. {$SETC UsingIncludes := CursorDevicesIncludes}
  208.  
  209. {$ENDC} {__CURSORDEVICES__}
  210.  
  211. {$IFC NOT UsingIncludes}
  212.  END.
  213. {$ENDC}
  214.